﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using NewDDSys.Entity;
using NewDDSys.IBLL;
using NewDDSys.IDAL;
using NewDDSys.Factory;
using NewDDSys.Utility;
using AjaxControlToolkit;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Web_YSJH : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            btnOK.Attributes.Add("onclick", "javascript:if(confirm('" + "确认无误，并提交么？" + "')== false) return false;");
            ddlKu.Items.Clear();
            ddlKu.Items.Add("请选择库区");
            DataSet ds = BLLFactory.CreateKcBLL().KF();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string ku = ds.Tables[0].Rows[i][0].ToString();
                ddlKu.Items.Add(ku);
            }
        }
        
    }
    public void ddlKu_SelectedIndexChanged(object sender, EventArgs e)
    {
        ddlPinzhong.Items.Clear();
        ddlPinzhong.Items.Add("请选择品种");
        if (ddlKu.SelectedIndex != 0)
        {
            DataSet ds = BLLFactory.CreateKcBLL().PByK(ddlKu.SelectedValue.ToString());
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string num = ds.Tables[0].Rows[i][0].ToString();
                ddlPinzhong.Items.Add(num);
            }
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        int checkValue = 0;
        YsjhInfo jh = new YsjhInfo();
        jh.Yday = txtYday.Text.ToString();
        jh.Ku = ddlKu.SelectedValue.ToString();
        jh.Pinzhong = ddlPinzhong.SelectedValue.ToString();
        jh.Cs = Convert.ToDecimal(txtCs.Text.ToString());
        jh.Xday = DateTime.Now.ToShortDateString();
        jh.Num = BLLFactory.CreateYsjhBLL().AUTOID();
        checkValue = BLLFactory.CreateYsjhBLL().AddYsjh(jh);
        if (checkValue >= 1)
        {
            Response.Write(" <script   language=javascript> window.alert( ' 提交成功！ ');</script> ");
        }
        Response.Redirect("YSJHJL.aspx");
    }
    protected void btnRepeat_Click(object sender, EventArgs e)
    {
        ddlKu.SelectedIndex = 0;
        ddlPinzhong.SelectedIndex = 0;
        txtCs.Text = "";

    }
}
